﻿using WorkflowCore.Interface;

namespace WebAPI.Configure;

public static class WorkflowCoreExtensions
{
    public static void AddBuildinWorkflowCore(this IServiceCollection services)
    {
        services.AddWorkflow();
        //services.AddWorkflow(x => x.UseSqlServer(@"Server=(LocalDb)\MSSQLLocalDB;Database=WorkflowCore;Trusted_Connection=True;", true, true));

    }

    public static void UseBuildinWorkflowCore(this IApplicationBuilder app)
    {
        var host = app.ApplicationServices.GetService<IWorkflowHost>();
        host.RegisterWorkflow<WorkflowCore.Sample03.PassingDataWorkflow, WorkflowCore.Sample03.MyDataClass>();
        host.RegisterWorkflow<WorkflowCore.Sample03.PassingDataWorkflow2, Dictionary<string, int>>();
        host.Start();

    }

}
